package cn.com.xinjinfu.pdoulcProduct.fragment.AboutPDou;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.alibaba.fastjson.JSON;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONObject;

import java.util.List;
import java.util.Map;

import cn.com.xinjinfu.pdoulcProduct.R;
import cn.com.xinjinfu.pdoulcProduct.adapter.MyInvestUniversalListAdaper;
import cn.com.xinjinfu.pdoulcProduct.engine.DataHandler;
import cn.com.xinjinfu.pdoulcProduct.entity.MyInvestListBean;
import cn.com.xinjinfu.pdoulcProduct.entity.User;
import cn.com.xinjinfu.pdoulcProduct.fragment.BaseFragment;
import cn.com.xinjinfu.pdoulcProduct.manager.AccountManager;
import cn.com.xinjinfu.pdoulcProduct.manager.ActivityManager;
import cn.com.xinjinfu.pdoulcProduct.manager.L;
import cn.com.xinjinfu.pdoulcProduct.manager.ToastManager;
import cn.com.xinjinfu.pdoulcProduct.view.LoadStatusBox;
import cn.com.xinjinfu.pdoulcProduct.view.ProgressWebView;
import cn.com.xinjinfu.pdoulcProduct.xlistview.XListView;

/**
 * 关于P兜
 * Created by android-adt on 2015/12/31.
 */
public class AboutFragment extends BaseFragment {
    private View viewFragment;
    private Activity mActivity;
    private ProgressWebView mWebView;
    private LoadStatusBox loadbox;
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        this.mActivity = activity;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        viewFragment = inflater.inflate(R.layout.fragment_about_pdou, null);
        return viewFragment;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mWebView = (ProgressWebView) view.findViewById(R.id.baseweb_webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        loadbox = (LoadStatusBox) view.findViewById(R.id.loadStatusBox);
        loadbox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                netCheck();
            }
        });
        loadbox.loading();
    }

    private void netCheck(){
        if (!DataHandler.isNetworkConnected(mActivity)) {
            loadbox.failed();
            return;
        }else {
            initData();
            loadbox.success();
        }
    }
    protected void initData( ) {
        String url = DataHandler.WEBURL +"/front/wa/appAboutPdou";
        mWebView.loadUrl(url);
        mWebView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                // TODO Auto-generated method stub
                view.loadUrl(url);
                return true;
            }
        });
    }

    @Override
    protected void lazyLoad() {
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mWebView = null;
    }

    @Override
    public String getFragmentName() {
        return null;
    }

}
